     let count=0;               //设置页面计数器
     
     
      var pageList=[];          //设置页面数组集合

      let firstPage=document.getElementById('first');
      let secondPage=document.getElementById('second');
      let thirdPage=document.getElementById('third');

      pageList.push(firstPage,secondPage,thirdPage);
      console.log(pageList[0])

      var startX, startY, endX, endY;
      //获取角度
      function getAngel(angeX, angeY) {
        return (Math.atan2(angeY, angeX) * 180) / Math.PI;
      }
      function direction() {
        var angeX = endX - startX;
        var angeY = endY - startY;
        var result = 0;
        // 如果滑动距离太短
        if ( Math.abs(angeY) < 50) {
          return result;
        }
        //根据起点终点返回方向 1向上 2向下  0未滑动
        var ange = getAngel(angeX, angeY);

        if (ange >= -135 && ange <= -45) {
          
          //上
          result = 1;
        } else if (ange > 45 && ange < 135) {
          // 下
          result = 2;
        }
        return result;
        
      }
    
      //手指接触屏幕
      document.addEventListener(
        "touchstart",
        function(e) {
          startX = e.touches[0].pageX;
          startY = e.touches[0].pageY;
        },
        false
      );
      
      //手指离开屏幕
      document.addEventListener(
        "touchend",
        function(e) {
          endX = e.changedTouches[0].pageX;
          endY = e.changedTouches[0].pageY;
          var result = direction();
          switch (result) {
            case 0:
             console.log('未触发事件')
              break;
            case 1:
              if(count<2){
                pageList[count].style.top='-100%';
                pageList[++count].style.top=0;
                //向上翻一页 页面计数器加1   向下反之 

              }else{
                console.log('最后一页了~');
              }   
              break;
            case 2:
              if(count==0){
                console.log('这是第一页');
              }else{
                pageList[--count].style.top='0';
                pageList[count+1].style.top='100%';
              }
              break;
          }
        },
        false
      );
